/*
简单二分即可,题目已经提供一升一降了
*/
#include<iostream>
#include<cstring>

using namespace std;

const int Max=50005;
int a[Max],b[Max];
int m,n;
int cnt=0;

bool div(int arr[],int b,int e,int key){
    while(b<=e){
        int mid=b+(e-b)/2;
        if(arr[mid]==key)
            return true;
        else if(arr[mid]>key){
            e=mid-1;
        }
        else{
            b=mid+1;
        }
    }
    return false;
}

int main(void){
    //cin>>m;
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf("%d",a[i]);
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",b[i]);
    }
    if(a[0]+b[n-1]>10000||a[m-1]+b[0]<10000){
        cout<<"NO"<<endl;   //已经不可能了
    }
    else{
        for(int i=0;i<n;i++){
            if(div(a,0,m-1,10000-b[i])){
                cout<<"YES"<<endl;
                break;
            }
            if(cnt++==n){
                cout<<"NO"<<endl;
                break;
            }
        }
    }
    return 0;
}